package com.lutzyt.delivery.controller;

import com.lutzyt.delivery.bean.Customer;
import com.lutzyt.delivery.bean.Horseman;
import com.lutzyt.delivery.service.CustomerService;
import com.lutzyt.delivery.service.HorsemanService;
import com.lutzyt.delivery.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zyt
 */
@Slf4j
@RestController
@RequestMapping("/api/admin/")
public class AdminController {

  private CustomerService customerService;
  private HorsemanService horsemanService;


  @GetMapping("/customer/current")
  public Result<Customer> currentCustomer(@RequestParam Integer id){
    final Customer customer = customerService.findById(id);
    return Result.success(customer);
  }

  @GetMapping("/horseman/current")
  public Result<Horseman> currentHorseman(@RequestParam Integer id){
    final Horseman horseman = horsemanService.findById(id);
    return Result.success(horseman);
  }

  @Autowired
  public void setHorsemanService(HorsemanService horsemanService) {
    this.horsemanService = horsemanService;
  }

  @Autowired
  public void setCustomerService(CustomerService customerService) {
    this.customerService = customerService;
  }
}
